Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classpath urls #1

Merged
merged 4 commits into from
Aug 9, 2023
Merged

Conversation

jkmatila
Copy link
Contributor

@jkmatila jkmatila commented Aug 8, 2023

Demonstrating the answer at https://stackoverflow.com/a/76857673/91822.

Please note that since the method of registering URLStreamHandlers is different between Java 8 and Java 9+, I changed the compile target to Java 9 to demonstrate the newer method here.

The method of registering URLStreamHandlers is a bit different in Java
9+ as compared to Java 8.  Here we are going to demonstrate the newer
method, so we'll change the compilation target to Java 9.
Introduce a URLStreamHandler for dereferencing 'cp:/' URLs, allowing to
retrieve the contents from classpath resources.  This implementation
supports an optional leading slash in the URL paths, which allows the
URLs to be treated as hiererchical, supporting the use of relative URL
references.
Change the test to use the cp:/ URLs to refer to the stylesheets
directly from the classpath.  This should now make the test pass.
Remove the XML catalog file, which is not needed in this solution.
(Note that the previous code did not actually seem to utilize it
either.)
@paulhoadley paulhoadley merged commit 93a015b into paulhoadley:master Aug 9, 2023
@paulhoadley
Copy link
Owner

Thanks @jkmatila! This is just outstanding. Works perfectly. I will tidy up this project and leave it up as a demonstration of how to run DocBook XSLT out of a JAR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants